package cn.spiral.test.conf;

import java.util.Calendar;

import org.quartz.CronTrigger;
import org.quartz.DateBuilder;
import org.quartz.DateBuilder.IntervalUnit;
import org.quartz.Job;
import org.quartz.JobBuilder;
import org.quartz.JobDataMap;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.SimpleTrigger;
import org.quartz.TriggerBuilder;
import org.quartz.impl.StdSchedulerFactory;

import cn.spiral.user.entity.User;

public class mian {

	/*public static void main(String[] args) {
		User user=new User();
		user.setAccount("123");
		user.setName("哈哈");
		JobDetail jobDetail=JobBuilder.newJob(f_min.class).withIdentity("jobDetail").usingJobData("s",10).build();
		JobDetail jobDetail2=JobBuilder.newJob(f5min.class).withIdentity("jobDetai2").build();
		JobDataMap jobDataMap=jobDetail.getJobDataMap();
		//jobDataMap.remove("s");
		jobDataMap.put("s", "12");
		jobDataMap.put("user", user);
		jobDetail.getJobBuilder().setJobData(jobDataMap);
		SimpleTrigger simpleTrigger= (SimpleTrigger) TriggerBuilder.newTrigger().withIdentity("simpleTrigger1").startAt(DateBuilder.futureDate(15, IntervalUnit.SECOND)).build();
		SimpleTrigger simpleTrigger2= (SimpleTrigger) TriggerBuilder.newTrigger().withIdentity("simpleTrigger2").startAt(DateBuilder.futureDate(5, IntervalUnit.SECOND)).build();
		Scheduler scheduler;
		try {
			scheduler = StdSchedulerFactory.getDefaultScheduler();
			scheduler.scheduleJob(jobDetail, simpleTrigger);
			scheduler.scheduleJob(jobDetail2, simpleTrigger2);
			scheduler.start();
		} catch (SchedulerException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}*/
	
	public static void main(String[] args) {
		JobDetail jobDetail1=JobBuilder.newJob(f_min.class).withIdentity("jobDetail1").usingJobData("s",10).build();
		//JobDetail jobDetail2=JobBuilder.newJob(f5min.class).withIdentity("jobDetai2").build();
		SimpleTrigger simpleTrigger1=(SimpleTrigger) TriggerBuilder.newTrigger().withIdentity("SimpleTrigger").startAt(DateBuilder.dateOf(23, 56, 10, 19, 11, 2017)).endAt(DateBuilder.dateOf(23, 56, 10, 19, 11, 2017)).build();
		Scheduler scheduler;
		try {
			scheduler = StdSchedulerFactory.getDefaultScheduler();
			scheduler.scheduleJob(jobDetail1,simpleTrigger1);
			//scheduler.scheduleJob(jobDetail2, simpleTrigger2);
			scheduler.start();
		} catch (SchedulerException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
